<?php


namespace App\Http\Requests\Manage\Customer;


use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AccountRequest
    extends FormRequest
{
    /**
     * @return array
     * @author: luffyzhao@vip.126.com
     * @datetime: 2019/3/28 13:26
     */
    public function rules(): array
    {
        return [
            'email' => ['required', 'email', Rule::unique('customer_users')
                ->where('customer_id', $this->route('id'))
                ->whereNotNull('role_id')
            ],
            'name' => ['required', 'min:2', 'max:20'],
            'phone' => ['required', 'regex:/^1[34578]\d{9}$/'],
            'status' => ['required', 'in:1,0'],
            'remark' => ['nullable', 'max:255'],
        ];
    }
}

